Add another action test
authorMatthias Clasen <mclasen@redhat.com>
Sun, 23 Jun 2019 01:38:27 +0000 (01:38 +0000)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 23 Jun 2019 01:39:34 +0000 (01:39 +0000)
Test that disabled actions aren't activated.

testsuite/gtk/action.c

index 7d44e2fc5db106e15a92adbc4f140f7eaa77db50..12dbb4254288f7fb112da61e5cf95eba518cf8ea 100644 (file)
@@ -388,6 +388,31 @@ test_introspection (void)
   g_type_class_unref (class);
 }
 
+/* Test that disabled actions don't get activated */
+static void
+test_enabled (void)
+{
+  GtkWidget *text;
+
+  text = gtk_text_new ();
+  g_signal_connect (text, "notify::visibility",
+                    G_CALLBACK (visibility_toggled), NULL);
+
+  toggled = 0;
+
+  gtk_widget_activate_action (text, "misc.toggle-visibility", NULL);
+
+  g_assert_cmpint (toggled, ==, 1);
+
+  gtk_widget_action_set_enabled (text, "misc.toggle-visibility", FALSE);
+
+  gtk_widget_activate_action (text, "misc.toggle-visibility", NULL);
+
+  g_assert_cmpint (toggled, ==, 1);
+
+  gtk_widget_destroy (text);
+}
+
 int
 main (int   argc,
       char *argv[])
@@ -399,6 +424,7 @@ main (int   argc,
   g_test_add_func ("/action/overlap", test_overlap);
   g_test_add_func ("/action/overlap2", test_overlap2);
   g_test_add_func ("/action/introspection", test_introspection);
+  g_test_add_func ("/action/enabled", test_enabled);
 
   return g_test_run();
 }